<!--
 * @Author: your name
 * @Date: 2021-12-16 15:51:04
 * @LastEditTime: 2021-12-16 16:23:41
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue-admin-template\src\pages\Privilege.vue
-->
<template>
  <div>
    <form>
      账户：<input type="text" :model="user">
      密码：<input type="text" :model="pass">
      <button @click="updateR">修改权限</button>
      <input type="button" value="登录" @click="Login">
    </form>
  </div>
</template>

<script>
  export default {
    name: "login",
    data(){
      return{
        user:'',
        pass:'',
        roles:'user'
      }
    },
    methods:{
      Login(){
        let dR = new Array(); 
        for (let i=0;i<dynamicRouter.length;i++){ 
          for (let j=0;j<dynamicRouter[i].meta.roles.length;j++){ 
            if (dynamicRouter[i].meta.roles[j] == this.roles){
              dR.push(dynamicRouter[i]); 
            }
          }
        }
        console.log(dR);
        this.$router.addRoutes(dR.concat([{ 
          path: '*',
          redirect: '/404' 
        }]));
        this.$router.push({path:'/home'}); 
      }
    },
    updateR(){
      if (this.roles === 'admin'){
        this.roles === 'user'
      } else{
        this.roles === 'admin'
      }
    }
  }
</script>

<style scoped>

</style>